﻿using System.IO;

namespace CI.Utility
{
    public static class StreamHelper
    {
        public static byte[] ReadByteArrayFromStream(Stream stream, long contentLength)
        {
            var len = (int)contentLength;
            var b = new byte[len];
            var pos = 0;
            var r = 0;
            while ((r = stream.Read(b, pos, len - pos)) > 0)
            {
                pos += r;
            }
            return b;
        }
    }
}